package com.wing.user.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wing.user.model.entity.User;
import com.wing.user.model.response.SysPhoneCodeVo;
import com.wing.user.model.response.UserAuthVO;
import com.wing.user.model.response.UserVO;
import com.wing.web.excel.UserExcelIn;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author
 */
@Mapper
public interface UserDao extends BaseMapper<User> {

    /**
     * 根据用户名或手机号获取用户
     * @param username
     * @return
     */
    UserAuthVO getByUsername(String username);

    UserAuthVO getByUserOrNickName(String username);

    /**
     * 根据手机号获取用户
     * @param phone
     * @return
     */
    UserAuthVO getByPhone(String phone);

    /**
     * 根据openId获取用户
     * @param openId
     * @return
     */
    UserAuthVO getByOpenId(String openId);

    User getByUserId(Long id);

    /**
     * 员工工号是否存在
     *
     * @param username 工号
     * @return {@link Integer}
     */
    Integer isExist(@Param("username") String username);

    /**
     * 添加通用数据
     * @param phone
     * @param code
     * @return
     */
    int addGeneralData(@Param("phone") String phone, @Param("code") String code);

    /**
     * 查询手机号是否已经存在
     * @param phone
     * @return
     */
    int queryPhoneExists(@Param("phone") String phone);

    /**
     * 查询通用数据
     * @param phone
     * @return
     */
    SysPhoneCodeVo querySysPhoneCode(@Param("phone") String phone);

    /**
     * 删除通用数据
     * @param phone
     * @return
     */
    int delGeneralData(@Param("phone") String phone);

    UserVO getUserInfoByUserId(@Param("userId") Long userId);

    UserVO getUserInfoByUserName (@Param("userName") String userName);

    List<UserExcelIn> exportList(Map paramsMap);

    List<User> list(@Param("page") Page<User> page, @Param("params") Map<String, Object> params);

    List<HashMap> costCenterBodyCount(@Param("startTime") LocalDateTime startTime, @Param("endTime")LocalDateTime endTime
            , @Param("param")String param, @Param("enterpriseId") Long enterpriseId, @Param("costCenter")String costCenter);

    HashMap costCenterBodyCountTotal(@Param("enterpriseId")Long enterpriseId);

    List<User> selUserDingInfo();

}
